/* vim: set tabstop=3: */
/*****************************************************************************
 * SwarmLexer.g : Lexer and Stub Parser for the Swarm Language               *
 *                                                                           *
 * SAMPLE USAGE:                                                             *
 * public class TestGrammar {                                                *
 *    public static void main(String[] args) throws Exception {              *
 *       SwarmLexer lex = new SwarmLexer(System.in);                         *
 *       SwarmParser parse = new SwarmParser(lex);                           *
 *       parse.expr();                                                       *
 *       System.out.println("Success!");                                     *
 *    }                                                                      *
 * }                                                                         *
 *                                                                           *
 * Consult the LRM for more information.                                     *
 * @author Rajesh                                                            *
 *****************************************************************************/

/* Uncomment the next three lines to use the package antlr.grammars.swarm */
/* header {
	package antlr.grammars.swarm;
}*/

class SwarmLexer extends Lexer;

options {
	k = 2;
	exportVocab=Swm;
}

CELLTYPE: (UPPER) ((UPPER) | '_' )* ;

INSTANCE: (LOWER)+ (DIGIT)*
        ;

FACET: '.' (LOWER) ((LOWER) | '_' | (DIGIT))* ;

protected
CROSSBIND: "->";

protected
DIRECTBIND: "=>";

END: ';';

NEW: ':';

LPAREN: '(';

RPAREN: ')';

WS: ( ' ' | '\t' 
    |  ("\r\n" | '\r' | '\n'){ newline(); } 
    ) { $setType(Token.SKIP); };

protected
ESCAPE:   '\\' (('b'|'t'|'n'|'f'|'r'|'"' /* " */ |'\''|'\\') | ESCAPE_OCTAL | ESCAPE_UNICODE);

protected
ESCAPE_OCTAL :  ('0'..'3') (options{warnWhenFollowAmbig=false;}
                : DIGIT (options{warnWhenFollowAmbig=false;}: DIGIT)? )?
             | ('4'..'7') (options{warnWhenFollowAmbig=false;}: DIGIT)?;

protected
ESCAPE_UNICODE : 'u' DIGIT_HEX DIGIT_HEX DIGIT_HEX DIGIT_HEX;

COMMA: ',';

LBRACKET: '[';

RBRACKET: ']';

protected
KILL: "-|";

protected
PUSH: ">>";

protected 
DIGIT: ('0'..'9');

protected
DIGIT_HEX : (DIGIT|'a'..'f'|'A'..'F') ;

protected
UPPER: ('A'..'Z');

protected
LOWER: ('a'..'z');

BINDTYPE: CROSSBIND | DIRECTBIND /* | KILL | PUSH */;

COMMENT: "/*" 
         ( options { generateAmbigWarnings=false; }
           : { LA(2)!='/' }? '*'
           | '\r' '\n' {newline();}
           | '\r' {newline();}
           | '\n' {newline();}
           | ~('*'|'\n'|'\r')
         )* 
         "*/" {$setType(Token.SKIP);}
         ;

STRING :  '"'! ( ESCAPE | ~('\\'|'"') )* '"'! ;

/* protected
ESCAPE:
  '\\'
  ( options{warnWhenFollowAmbig=false;}:
    'a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' | '"' | '\'' | '\\' | '?'
    | ('0'..'3') (options{warnWhenFollowAmbig=false;}: DIGIT (options{warnWhenFollowAmbig=false;}: DIGIT)? )?
    | ('4'..'7') (options{warnWhenFollowAmbig=false;}: DIGIT)?
    | 'x' (options{warnWhenFollowAmbig=false;}: DIGIT | 'a'..'f' | 'A'..'F')+
  );
*/
